import request from '@/utils/request'
import {getAccount} from '@/utils/auth'

export function addRolesToUser(url,params){
  return request({
    url: url,
    method: 'put',
    data:params
  })
}


export function getUserRoles(url) {
  return request({
    url: url,
    method: 'get'
  })
}

export function searchByParam(params) {
  return request({
    url: '/get/user/infos/by/params',
    method: 'post',
    data: params
  })
}

export function deleteUserByList(uids) {
  return request({
    url: '/del/by/uids',
    method: 'delete',
    data: uids
  })
}

export function insertUser(params) {
  return request({
    url: '/add/new/user',
    method: 'post',
    data: params
  })
}

export function updateUserById(params) {
  return request({
    url: '/update/user/by/uid',
    method: 'put',
    data: params
  })
}

export function deleteUserById(url) {
  return request({
    url: url,
    method: 'delete'
  })
}

export function getUserList(url) {
  return request({
    url: url,
    method: 'get'
  })
}

export function login(data) {
  return request({
    url: '/usr/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/vue-admin-template/user/info',
    method: 'get',
    params: { token }
  })
}

export function upLoad(param) {
  return request({
    url: '/upload/avator/img',
    method: 'post',
    data:param
  })
}

export function updateImg(param) {
  return request({
    url: '/update/avator/by',
    method: 'post',
    data:param
  })
}

export function logout() {

  let account = getAccount()

  let data = {
    account:account
  }

  return request({
    url: '/usr/logout',
    method: 'post',
    data:data
  })
}
